/**
 * Order 业务逻辑
 * @author WangXinLei
 * @date 2014-11-05
 */
package com.chnbst.bstyun.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.Cashflow;
import com.chnbst.bstyun.model.vo.CashflowVo;
import com.chnbst.bstyun.service.CashflowService;

@Transactional
@Service
public class CashflowServiceImpl extends BaseService implements CashflowService{

	//声明日志对象 logback
	private final static Logger logger = LoggerFactory.getLogger(CashflowServiceImpl.class);
	private final static String nameSpace = "com.chnbst.bstyun.mapper.CashflowMapper";
		
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public CashflowVo selectByCashflowId(Integer cashflowId) {
		return (CashflowVo) DaoHelper.query(nameSpace, "selectByCashflowId", cashflowId);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean deleteByCashflowId(Integer cashflowId) {
		// TODO Auto-generated method stub
		return false;
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean insertCashflow(Cashflow cashflow) {
		return DaoHelper.insert(nameSpace, "insertCashflow", cashflow);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean updateByCashflowId(Cashflow cashflow) {
		return DaoHelper.update(nameSpace, "updateByCashflowId", cashflow);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public List<CashflowVo> selectCashflowsByCondition(Map<String, Object> map) {
		return (List<CashflowVo>)DaoHelper.list(nameSpace, "selectCashflowsByCondition", map);
	}

	@Override
	public String selectBigNumByDealType(String dealType) {
		return (String) DaoHelper.query(nameSpace, "selectBigNumByDealType", dealType);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public List<CashflowVo> selectCashflows(Map<String, Object> map) {
		return (List<CashflowVo>)DaoHelper.list(nameSpace, "selectCashflows", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public CashflowVo selectCashflowsByUserId(Integer userId) {
		return (CashflowVo)DaoHelper.query(nameSpace, "selectCashflowsByUserId", userId);
		
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public Double selectAccountMoneyByPayWayId(Integer payWayId) {
		return (Double)DaoHelper.query(nameSpace, "selectAccountMoneyByPayWayId", payWayId);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public int selectCashflowsCountByPayWayId(Map<String, Object> map) {
		return DaoHelper.count(nameSpace, "selectCashflowsCountByPayWayId", map);
	}
	
	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public List<CashflowVo> selectCashflowsByPayWayId(Map<String, Object> map) {
		return (List<CashflowVo>)DaoHelper.list(nameSpace, "selectCashflowsByPayWayId", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public CashflowVo selectCashflowByCashflowNum(String cashflowNum) {
		return (CashflowVo)DaoHelper.query(nameSpace, "selectCashflowByCashflowNum", cashflowNum);
	}
}
